home *** CD-ROM | disk | FTP | other *** search
/ Exame Informatica 139 / Exame Informatica 139.iso / Revista / Flash / Uniform Server / diskw / home / admin / www / aconfig.php < prev    next >
Encoding:
PHP Script  |  2005-07-08  |  4.6 KB  |  161 lines

  1. <?
  2. /*
  3. ####################################################
  4. # Name: The Uniform Server Admin Panel 2.0
  5. # Developed By: The Uniform Server Development Team
  6. # Modified Last By: Olajide Olaolorun (empirex)
  7. # Web: http://www.uniformserver.com
  8. ####################################################
  9. */
  10.  
  11. // Includes
  12. include "includes/config.inc.php";
  13. include "$apanel_path/includes/lang/".file_get_contents("includes/.lang").".php";
  14. include "includes/header.php";
  15. ?>
  16.  
  17. <div id="main">
  18. <h2>» <?=$US['aconfig-head']?></h2>
  19. <h3><?=$US['aconfig-conf']?></h3>
  20. <?
  21. # -- Determines Apache version.
  22. if (preg_match("/Apache\/2/i", $_SERVER["SERVER_SOFTWARE"])) {
  23.         $Apache2 = True;
  24. }
  25. else {
  26.         $Apache2 = False;
  27. }
  28. # --
  29.  
  30. # -- Determines PHP mode
  31. if (!preg_match("/^cgi/",php_sapi_name())) {
  32.         $PHPmod = True;
  33. }
  34. else {
  35.         $PHPmod = False;
  36. }
  37. # --
  38.  
  39. $apache = new Config ("/usr/local/apache2/conf/httpd.conf","#");
  40. $apache->Var_Name =array ("ServerName","ServerAdmin","DirectoryIndex","AddHandler server-parsed","ServerSignature");
  41. $apache->Var_Text =array (
  42. "".$US['aconfig-sname']."","".$US['aconfig-wemail']."","".$US['aconfig-difiles']."",
  43. "".$US['aconfig-ssi']."","".$US['aconfig-ssig']."");
  44. $apache->Var_Help =array (
  45. "http://httpd.apache.org/docs/mod/core.html#servername",
  46. "http://httpd.apache.org/docs/mod/core.html#serveradmin",
  47. "http://httpd.apache.org/docs/mod/mod_dir.html#directoryindex",
  48. "http://httpd.apache.org/docs/mod/mod_include.html",
  49. "http://httpd.apache.org/docs/mod/core.html#serversignature");
  50.  
  51.  
  52. // import_request_variables("gP", "st");
  53. $step=$HTTP_POST_VARS['Submit'];
  54. if ($step == "next") {
  55.         echo "<p>".$US['aconfig-text-0']."</p>";
  56. }
  57.  
  58. else {
  59.         if ($step == "Save") {
  60.                 $apache->replace_values ($HTTP_POST_VARS);
  61.                 echo "<p><font color=\"red\">".$US['aconfig-text-1']."</font><p>";
  62.         }
  63. ?>
  64.  
  65.         <form action="
  66. <?
  67.         echo $_SERVER["PHP_SELF"]."\" name=\"f\" method=\"post\">";
  68.         $apache->echo_values ();
  69. ?>
  70.         <br />
  71.         <input type="submit" value="<?=$US['aconfig-save']?>" name="Submit" />
  72.         </form>
  73.         <br />
  74. <?
  75.         if ($PHPmod==True) {
  76.                 echo "<p><font color=\"red\">".$US['aconfig-module']."</font></p>";
  77.         }
  78.  
  79.         else {
  80.                 echo "<p><font color=\"red\">".$US['aconfig-cgi']."</font></p>";
  81.         }
  82. }
  83.  
  84. //--------------------------------------------------------------------
  85. class Config
  86. {
  87. var $contents;
  88. var $name;
  89. var $comments;
  90. var $Var_Name;
  91. var $Var_Text;
  92. var $Var_Help;
  93. var $classnum;
  94.  
  95. function Config ($file_name, $comments)
  96. {
  97.       $this->comments=$comments;
  98.       $this->name=$file_name;
  99.       $fd = fopen ($this->name, "r");
  100.       $this->contents = fread ($fd, filesize ($file_name));
  101.       fclose ($fd);
  102.       $this->classnumber=$GLOBALS["$Configclassnumber"]=$GLOBALS["$Configclassnumber"]+1;
  103. }
  104.  
  105. function f_write ()
  106. {
  107.       $fd = fopen ($this->name, "w");
  108.       $ok = fwrite ($fd, $this->contents);
  109.       fclose ($fd);
  110. }
  111.  
  112. function echo_values ()
  113. {
  114.       include "includes/lang/".file_get_contents("includes/.lang").".php";
  115.       echo "<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">";
  116.       $item=0;
  117.  
  118.       foreach ($this->Var_Name as $loop){
  119.             $Var_ID="C".$this->classnumber."i".$item;
  120.             $Var_Name=$this->Var_Name[$item];
  121.             $Var_Text=$this->Var_Text[$item];
  122.             $Var_Help=$this->Var_Help[$item];
  123.             $comments=$this->comments;
  124.             preg_match("/\n\s*$Var_Name\s+([^$comments^\n]+)/i", $this->contents, $tag);
  125.             echo "
  126.                 <tr>
  127.                 <td width=\"150\"><p>$Var_Text:</p></td>
  128.                 <td>
  129.                 <p><input type=\"text\" name=\"$Var_ID\" size=\"31\" maxlength=\"2048\" value='$tag[1]' /> ";
  130.             if ($Var_Help != "") {echo "<a href=\"$Var_Help\" target=\"_help\">".$US['aconfig-help']."</a>";};
  131.                 echo "</p>";
  132.             echo "</td>";
  133.                 echo "</tr>";
  134.             $item=$item+1;
  135.         }
  136.  
  137.       echo "</table>";
  138. }
  139.  
  140. function replace_values ($HTTP_POST_VARS)
  141. {
  142.       $item=0;
  143.  
  144.       foreach ($this->Var_Name as $loop){
  145.             $Var_ID="C".$this->classnumber."i".$item;
  146.             $data=$HTTP_POST_VARS[$Var_ID];
  147.             $comments=$this->comments;
  148.             $this->contents=preg_replace("/\n(\s*$loop)\s+([^$comments]+)/i", "\n\\1 $data\n\n", $this->contents, 1);
  149.             $item=$item+1;
  150.       }
  151.  
  152.       $this->f_write ();
  153. }
  154. }
  155. ?>
  156. </div>
  157.  
  158. <?
  159. // Footer
  160. include "includes/footer.php";
  161. ?>